#include "GrfPack.hpp"

int main()
{
    GrfFile myGrf;

	// Create an empty GRF
	switch (myGrf.create("test.grf")) {
	case GRF_OK:
		std::cout<<"File not exists. Creating file..."<<std::endl;
		
		// Set compression level to 5
		myGrf.compressionLevel(5);

		// Insert image into GRF
        myGrf.insert("Looking_For_Heaven.jpg", "data\\load.jpg");

		// Save it!
		myGrf.save();
		
		// Close it!
        myGrf.close();
		break;
	case GRF_FILE_EXISTS:
		std::cout<<"File exists."<<std::endl;

		// If create() is not ok, then we must load it again...
		myGrf.load("test.grf");

		// Extract each files
		for (int i = 0; i < myGrf.getFileCount(); i++) {
			GrfItem *item = myGrf.getItem(i);
			std::cout<<"Extracting: "<<item->getName()<<std::endl;

			// Save files as their default name
			item->save(item->getName());
		}

		myGrf.close();
		break;
	default:
		std::cout<<"Unexpected error.."<<std::endl;
		break;
	}

	return 0;
}
